Convert from ModName_ to Module

I am using DOORS 7.1.

I am able to obtain a handle of type ModName_ to a DOORS module. Some functions require the Module type instead. The only constructor that I have found for type Module is

Module module (Item +itemRef+).

I have found a convoluted way to convert from ModName_ to Item using the following two functions

string uniqueID (...ModName_ +modRef+)
Item itemFromID (string +uniqueID+)

But is there a more straightforward way to convert ModName_ to Module?
SystemAdmin - Sat May 09 01:59:28 EDT 2009

Re: Convert from ModName_ to Module
SystemAdmin - Sat May 09 06:29:38 EDT 2009

Note in DXL Help that for the function module it says: "The first form returns a handle of type Module for itemRef if itemRef is an open module."

So a module handle of the form ModName_ is a handle for all modules, whether closed or open, but a handle of type Module is for open modules. You need ModName_ for some operations, and Module for some others.

If you need a Module handle, open the module by either a read, share or edit function:
 

string ModuleName = "/blaa/blaa/blaa"
ModName ModRef = module ModuleName
Module Mod = read(fullName ModRef, false)

 


of course instead of going through the ModRef route you could get the Module handle directly in above example by Module Mod = read(ModuleName, false).

If you want to get a module from an item then the corresponding would be
Module Mod = read(fullName itemRef, false).

 

Re: Convert from ModName_ to Module
llandale - Sun May 10 11:50:09 EDT 2009

Yes, open it read/share/edit. Your method is good if for some reason you only want the Module handle if its already open; or if you don't want a Module handle if its not already open.

Re: Convert from ModName_ to Module
SystemAdmin - Mon May 11 13:10:17 EDT 2009

SystemAdmin - Sat May 09 06:29:38 EDT 2009

Note in DXL Help that for the function module it says: "The first form returns a handle of type Module for itemRef if itemRef is an open module."

So a module handle of the form ModName_ is a handle for all modules, whether closed or open, but a handle of type Module is for open modules. You need ModName_ for some operations, and Module for some others.

If you need a Module handle, open the module by either a read, share or edit function:
 

string ModuleName = "/blaa/blaa/blaa"
ModName ModRef = module ModuleName
Module Mod = read(fullName ModRef, false)

 


of course instead of going through the ModRef route you could get the Module handle directly in above example by Module Mod = read(ModuleName, false).

If you want to get a module from an item then the corresponding would be
Module Mod = read(fullName itemRef, false).

 

Thanks.

Surprisingly, I'm having trouble with the simple task of verifying the existence of two modules. The code looks like this

ModName_ aModule = module("/Project name with lots of spaces/folder1/folder2/modulename")
ModName_ anotherModule = module("/Project name with lots of spaces/folder with spaces/module with spaces")

All I want to do at this point is call exists successfully

if (exists(axModule))
logsomething

It isn't working. I've tried replacing spaces with underscores and deleting the spaces altogether.

The two modules in question are not open, nor should they be.

Re: Convert from ModName_ to Module
llandale - Mon May 11 18:09:54 EDT 2009

SystemAdmin - Mon May 11 13:10:17 EDT 2009
Thanks.

Surprisingly, I'm having trouble with the simple task of verifying the existence of two modules. The code looks like this

ModName_ aModule = module("/Project name with lots of spaces/folder1/folder2/modulename")
ModName_ anotherModule = module("/Project name with lots of spaces/folder with spaces/module with spaces")

All I want to do at this point is call exists successfully

if (exists(axModule))
logsomething

It isn't working. I've tried replacing spaces with underscores and deleting the spaces altogether.

The two modules in question are not open, nor should they be.

Looking at 'exists' in 'Module information' in the DXL manual, I see it makes a reference to 'the current project'. Very interesting.

Here's my function, just get rid of 'fFullName()', which will find a partially qualified name in the current project. It will work if you send it a fully qualified name (/proj/fold/mod).
 

//**********************
bool    fIsValidModule(string NameMod, string ModType)
{     // Determine if the Module name is a valid module of the specified
        //   Type "Formal", "Link", or "Descriptive" in the current project.
        //   Type = "*" means any type (of module).
        // 'Valid' modules:
        //   o Exist and are not deleted.
        //   o Available for Read to the current user.
        // Search rules for 'fFullName' above apply to this function.
        
        if (null NameMod or null ModType) return(false)
 
        bool    OKname
        string  FullName = fFullName(NameMod)
 
        if (null FullName                       or
            !module FullName                    or
            isDeleted(module FullName)  or
            (ModType != "*" and type(module FullName) != ModType)
           )
             OKname = false
        else OKname = true
 
//    if (!null NameMod and !null ModType)
//      print "fIsValidModule: " OKname " '" NameMod "' ^" ModType "^\n"
//    else print "fIsValidModule: bad input names\n"
 
        return(OKname)
}     // end fIsValidModule()

 


>Louie

 

Re: Convert from ModName_ to Module
SystemAdmin - Mon May 11 23:24:51 EDT 2009

llandale - Mon May 11 18:09:54 EDT 2009

Looking at 'exists' in 'Module information' in the DXL manual, I see it makes a reference to 'the current project'. Very interesting.

Here's my function, just get rid of 'fFullName()', which will find a partially qualified name in the current project. It will work if you send it a fully qualified name (/proj/fold/mod).
 

//**********************
bool    fIsValidModule(string NameMod, string ModType)
{     // Determine if the Module name is a valid module of the specified
        //   Type "Formal", "Link", or "Descriptive" in the current project.
        //   Type = "*" means any type (of module).
        // 'Valid' modules:
        //   o Exist and are not deleted.
        //   o Available for Read to the current user.
        // Search rules for 'fFullName' above apply to this function.
        
        if (null NameMod or null ModType) return(false)
 
        bool    OKname
        string  FullName = fFullName(NameMod)
 
        if (null FullName                       or
            !module FullName                    or
            isDeleted(module FullName)  or
            (ModType != "*" and type(module FullName) != ModType)
           )
             OKname = false
        else OKname = true
 
//    if (!null NameMod and !null ModType)
//      print "fIsValidModule: " OKname " '" NameMod "' ^" ModType "^\n"
//    else print "fIsValidModule: bad input names\n"
 
        return(OKname)
}     // end fIsValidModule()

 


>Louie

 

> llandale wrote:
> Looking at 'exists' in 'Module information' in the DXL manual, I see it makes a reference to 'the current project'. Very interesting.
>Louie

The module running the script is located in the same project as the other modules. However, getting exists to work is not critical. I have handed my task off to someone with more expertise in DXL as I have succeeded in writing the text parsing portion.

Re: Convert from ModName_ to Module
SystemAdmin - Wed Jun 10 19:20:37 EDT 2009

llandale - Mon May 11 18:09:54 EDT 2009

Looking at 'exists' in 'Module information' in the DXL manual, I see it makes a reference to 'the current project'. Very interesting.

Here's my function, just get rid of 'fFullName()', which will find a partially qualified name in the current project. It will work if you send it a fully qualified name (/proj/fold/mod).
 

//**********************
bool    fIsValidModule(string NameMod, string ModType)
{     // Determine if the Module name is a valid module of the specified
        //   Type "Formal", "Link", or "Descriptive" in the current project.
        //   Type = "*" means any type (of module).
        // 'Valid' modules:
        //   o Exist and are not deleted.
        //   o Available for Read to the current user.
        // Search rules for 'fFullName' above apply to this function.
        
        if (null NameMod or null ModType) return(false)
 
        bool    OKname
        string  FullName = fFullName(NameMod)
 
        if (null FullName                       or
            !module FullName                    or
            isDeleted(module FullName)  or
            (ModType != "*" and type(module FullName) != ModType)
           )
             OKname = false
        else OKname = true
 
//    if (!null NameMod and !null ModType)
//      print "fIsValidModule: " OKname " '" NameMod "' ^" ModType "^\n"
//    else print "fIsValidModule: bad input names\n"
 
        return(OKname)
}     // end fIsValidModule()

 


>Louie

 

I am back on task.

Where are the rules in Help on how to form a proper partially qualified name?

Re: Convert from ModName_ to Module
llandale - Thu Jun 11 12:17:23 EDT 2009

SystemAdmin - Wed Jun 10 19:20:37 EDT 2009
I am back on task.

Where are the rules in Help on how to form a proper partially qualified name?

On task, off topic.

There are no rules in the Help for partially qualified names. After reading what I believe are the rules below, you are likely to conclude that you shouldn't use them in DXL, except perhaps as names displayed to the user.

o Partial and Unqualified names are relative to the 'current' folder. Trying to open "MyFolder/MyModule" means there should be a folder named 'MyFolder' in the current folder. To make that happen you may need to set current = fCurr to such a parent folder.
o The 'current' folder may change as you open up modules, which may change the 'current' module.
o Each slash-separated field of a name must correspond as-is to some item. "MyFolder/MyModule" will NOT match "alsoMyFolder/MyModule" nor "MyFolder/MyModule-1".
o While full names are unique in the database, partial and unqualified names are not.
o Unqualified names are residual from DOORS v4 days when there were no folders, just a project. Some commands still return unqualified names, but they are now useless (string source(Link) comes to mind).

No, generally store such information as either full names or as Project/Folder/Module handles.

  • Louie

Re: Convert from ModName_ to Module
faisal.zahidi@boeing.com - Mon Dec 14 18:52:32 EST 2009

SystemAdmin - Sat May 09 06:29:38 EDT 2009

Note in DXL Help that for the function module it says: "The first form returns a handle of type Module for itemRef if itemRef is an open module."

So a module handle of the form ModName_ is a handle for all modules, whether closed or open, but a handle of type Module is for open modules. You need ModName_ for some operations, and Module for some others.

If you need a Module handle, open the module by either a read, share or edit function:
 

string ModuleName = "/blaa/blaa/blaa"
ModName ModRef = module ModuleName
Module Mod = read(fullName ModRef, false)

 


of course instead of going through the ModRef route you could get the Module handle directly in above example by Module Mod = read(ModuleName, false).

If you want to get a module from an item then the corresponding would be
Module Mod = read(fullName itemRef, false).

 

why I cannot close my open modules while looping thru skiplist

for modpath in skopenMod do
{
//key=Ground Segment Spec modpath=/MSV/L2/Ground Segment Spec

string srcName=(string key(skopenMod))
string ModuleName= modpath
ModName ModRef = module ModuleName
Module Mod=read(fullName ModRef,false)
close Mod

}

Re: Convert from ModName_ to Module
ePiallat - Tue Dec 15 04:21:43 EST 2009

faisal.zahidi@boeing.com - Mon Dec 14 18:52:32 EST 2009
why I cannot close my open modules while looping thru skiplist

for modpath in skopenMod do
{
//key=Ground Segment Spec modpath=/MSV/L2/Ground Segment Spec

string srcName=(string key(skopenMod))
string ModuleName= modpath
ModName ModRef = module ModuleName
Module Mod=read(fullName ModRef,false)
close Mod

}

Hi

Opening a module (with read) just in order to closing it seems a bit overkill.

You maybe should consider using the Module module(Item) perm instead:

if (module modpath) {
    Module mod = module item modpath
    if (!(null mod)) close mod
  }


 


By the way, because a key in a skip list should be unique, you should consider using module's fullname instead of module's name as a key.

- Éric